HttpWatch Automation Reference - Version 15.x
Using HttpWatch Automation with Ruby / Ruby - Overview
In This Topic
    Ruby - Overview
    In This Topic

    Prerequisites

    You can install the Ruby language runtime using the installer at http://rubyinstaller.org/ .

    Accessing HttpWatch from Ruby

    The HttpWatch automation library is packaged as a COM component. To access it from Ruby you will need to use WIN32OLE::new from the win32ole library. It can be referenced by adding the following require statement to your Ruby source file:

    Using the WIN32OLE library
    Copy Code
    require 'win32ole'
    

    Communicating with the HttpWatch Extension

    You can only directly create an instance of one class in the library - the Controller class.

    All communication with the HttpWatch extension stems from this class, so the first step is to create an instance of it:

     

    Creating the Controller
    Copy Code
    # Controller is the only creatable class in the HttpWatch automation interface
    
    controller = WIN32OLE.new('HttpWatch.Controller')
    

     

    Having created a Controller object, the next step is to create an instance of the extension and attach it to a browser instance. The exact code depends on whether you are using Google Chrome or Microsoft Edge, but the principles are the same in either case. The Controller object has a property named Chrome. This property returns a reference to the Chrome object.

    The New method creates a new instance of the Chrome browser with the HttpWatch extension enabled for automation. AttachByTitle allows the user to use the HttpWatch extension within a browser instance that has already been created by some other component. Both methods return a reference to the Plugin object that represents the HttpWatch extension.

    The following code creates a new instance of a Chrome tab with an attached HttpWatch plugin object:

    Creating the HttpWatch extension for Chrome
    Copy Code
    controller = WIN32OLE.new('HttpWatch.Controller')
    
    plugin = controller.Chrome.New()
    

    For Microsoft Edge using the Edge property of the controller instead.

    All of these code fragments return a reference to a Plugin object, through which the HttpWatch extension can be controlled.

    See Also